from time import sleep
import uiautomation
import pyautogui
class chufangfayao():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()

        chaxun = his.ButtonControl(AutomationId='search_btn', ClassName='Button',Name='查询')#查询
        fayao = his.ButtonControl( ClassName='Button',Name='发药(F8)')#发药


        yaofang1 = his.ComboBoxControl(AutomationId='yflst_cb',ClassName='ComboBox') #药房选择框
        yaofang2= yaofang1.ListItemControl( ClassName='ListBoxItem',Name='药房(4007)')#药房
        cailiaofang = yaofang1.ListItemControl( ClassName='ListBoxItem',Name='材料房(333336)')#材料房

        xingmingshurukang = his.EditControl(AutomationId='pname_txt',ClassName='TextBox')#姓名输入框

        zhuangtai = his.ComboBoxControl(AutomationId='fyCombo',ClassName='ComboBox') #状态选择框
        daifayao = zhuangtai.ListItemControl(ClassName='ListBoxItem',Name='Yuanbo.ChssClient.DrugManagement.ViewModel.FYState',foundIndex=1)#待发药
        yifayao = zhuangtai.ListItemControl(ClassName='ListBoxItem',Name='Yuanbo.ChssClient.DrugManagement.ViewModel.FYState',foundIndex=2)#已发药
        yituiyao = zhuangtai.ListItemControl(ClassName='ListBoxItem',Name='Yuanbo.ChssClient.DrugManagement.ViewModel.FYState',foundIndex=3)#已退药
        bufentuiyao = zhuangtai.ListItemControl(ClassName='ListBoxItem',Name='Yuanbo.ChssClient.DrugManagement.ViewModel.FYState',foundIndex=4)#部分退药

        shujuwangge = his.DataGridControl(AutomationId='dfyry_ydg',ClassName='YDataGrid')
        shuju1 = shujuwangge.DataItemControl(ClassName='DataGridRow',Name='Ksy.ChssClient.Access.Model.DLYLIST',foundIndex=1)
        shuju2 = shujuwangge.DataItemControl(ClassName='DataGridRow',Name='Ksy.ChssClient.Access.Model.DLYLIST',foundIndex=2)
        shuju3 = shujuwangge.DataItemControl(ClassName='DataGridRow',Name='Ksy.ChssClient.Access.Model.DLYLIST',foundIndex=3)


        tishi = his.WindowControl(ClassName='Window',Name='温馨提示')
        queding = tishi.ButtonControl(AutomationId='OkBtn',ClassName='Button',Name='确定')
        quxiao = tishi.ButtonControl(AutomationId='CancelBtn',ClassName='Button',Name='取消')

        #选择西药房
        def choose_yf(self):
                self.yaofang1.Click()
                self.yaofang2.Click()
        #选择中药房
        def choose_clyf(self):
                self.yaofang1.Click()
                self.cailiaofang.Click()

        # 选择待发药
        def choose_dfy(self):
                self.zhuangtai.Click()
                self.daifayao.Click()

        # 选择已发药
        def choose_yfy(self):
                self.zhuangtai.Click()
                self.yifayao.Click()

        # 选择已退药
        def choose_yty(self):
                self.zhuangtai.Click()
                self.yituiyao.Click()

        # 选择部分退药
        def choose_bfty(self):
                self.zhuangtai.Click()
                self.bufentuiyao.Click()

        #输入姓名
        def input_name(self,name):
                self.xingmingshurukang.Click()
                pyautogui.hotkey('ctrl', 'a')
                pyautogui.press('back')
                self.xingmingshurukang.SendKeys(name)

        #点击查询按钮
        def click_cx_btn(self):
                self.chaxun.Click()

        #点击发药
        def click_fy_btn(self):
                self.fayao.Click()
        #点击提示确定按钮
        def click_qd_btn(self):
                self.queding.Click()
        #点击提示取消按钮
        def click_qx_btn(self):
                self.quxiao.Click()

        #选择数据1
        def choose_sj1(self):
                self.shuju1.DoubleClick()

        #选择数据2
        def choose_sj2(self):
                self.shuju2.DoubleClick()

        #选择数据3
        def choose_sj3(self):
                self.shuju3.DoubleClick()